<template>
  <div class="specialist-detail ct">
    <el-breadcrumb class="head-nav" :separator-icon="ArrowRight">
      <el-breadcrumb-item :to="{ path: '/yardhome',query: {yardId} }">站院首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/yardstudeng',query: {yardId} }">驻站学生</el-breadcrumb-item>
      <el-breadcrumb-item>研究生详情</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="detail-content">
      <div class="content-t">
        <div class="t-name">
          <img :src="intro.photo" alt="">
          <div class="name-r">
            <div class="t-name1">{{ intro?.name }}</div>
            <div class="t-name2">专业：{{ intro?.speciality }}</div>
            <div class="t-name3">入住时间：{{ intro?.checkInDate }}</div>
          </div>
   
        </div>
        <div class="t-num">
          <div class="num-n">{{ detailRef.total }}</div>
          <div class="num-t">研究生日志数</div>
        </div>
      </div>
      <div class="content-b">
        <div class="content-item" @click="goDetail(item.logId)" v-for="item, index in detailRef.list">
          <div class="item-l">
            <div class="l1">{{ index+1 }}</div>
            <div class="l2">{{ item.logDate }}</div>
          </div>
          <div class="item-r">
            <div class="r1">{{ item.logTitle }}</div>
            <div class="r2">{{ item.logPeriods }}</div>
          </div>
        </div>
      </div>

      <div class="item-page">
          <el-pagination
            v-model:current-page="detailRef.page"
            :page-size="15"
            background
            layout="prev, pager, next, jumper"
            prev-text="上一页"
            next-text="下一页"
            :total="detailRef.total"
            @current-change="getpageCourtyardLogByPostgraduateId"
          />
        </div>
    </div>
  </div>
</template>
<script setup>
import { ArrowRight } from '@element-plus/icons-vue'
import { getPostgraduate, pageCourtyardLogByPostgraduateId, countCourtyardLogByPostgraduateId } from '@/api/home'
import { useRouter } from 'vue-router';
import { computed, ref, reactive } from 'vue';

const router = useRouter();
const id = computed(() => router?.currentRoute?.value?.params.id)
const intro = ref({})
const yardId = computed(() => router?.currentRoute?.value?.query.yardId)
const detailRef = reactive({});

init()
async function init(){
  const { data } = await getPostgraduate({postgraduateId:id.value});
  intro.value = data;
  console.log('---data', data)

  const ret1 = await countCourtyardLogByPostgraduateId({params: {postgraduateId:id.value,courtyardId: yardId.value}});
  console.log('---ret1', ret1)
  detailRef.total = ret1?.data;


  getpageCourtyardLogByPostgraduateId()


}

const goDetail = (id) => {
    router.push(`/yardLogDetail/${id}?type=yardlog&yardId=${yardId.value}`)
  }


 const getpageCourtyardLogByPostgraduateId = async (pageNum=1) => {
  const ret2 = await pageCourtyardLogByPostgraduateId({params:{postgraduateId:id.value,courtyardId: yardId.value},page: {pageSize: 15, pageNum}});

  console.log('---ret2', ret2)
  detailRef.list = ret2?.data?.list || [];
  detailRef.page = pageNum;
 }




</script>
<style lang="scss" scoped>
  .specialist-detail {
    width: 100%;
    color: #777;
    padding: 0 10%;
    background: #f5f5f5 url('../../assets/job/6.png') no-repeat 0 200px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .head-nav {
    height: 125px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 24px;
    width: 100%;
  }
  .detail-content {
    width: 100%;
    margin-bottom: 60px;
    flex: 1;
    overflow: hidden;
    // display: flex;
    // justify-content: space-between;
    .content-t {
      display: flex;
      height: 200px;
      .t-name {
        display: flex;
        background-color: #068043;

        img {
          width: 100px;
          width: 100px;
          object-fit: contain;
        }
        .name-r {
          color: #fff;
          background-color: #4aa97d;
          padding-left: 24px;
          padding-right: 100px;
          padding-top: 20px;
          .t-name1 {
            font-size: 30px;
            padding-bottom: 10px;
          }
          .t-name2 {
            font-size: 20px;
            padding-bottom: 10px;
          }
          .t-name3 {
            font-size: 20px;
          }
        }

      }
      .t-num {
        margin-left: 30px;
      background-color: #fff;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 200px;
      height: 100%;
      overflow: hidden;
      .num-n {
        font-size: 80px;
      color: #068043;
      font-weight: bold;
    }
      .num-t {
        font-size: 20px;
        color: #333;
      }

      }
    }
    .content-b {
      .content-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background-color: #fff;
        margin-top: 30px;
        padding: 30px 30px;
        box-sizing: border-box;
        color: #333;
        cursor: pointer;
        .item-l {
          width: 180px;
        height: 160px;
          border: 1px solid #e1e1e1;
          font-size: 30px;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          color: #777;
          .l1 {
            font-weight: 500;
            font-size: 40px;
            color: #333;
          }
          .l2 {
            font-size: 24px;
          }
        }
        .item-r {
          flex: 1;
          padding-left: 30px;
          .r1 {
            font-size: 30px;
            font-weight: 500;
            padding-bottom: 10px;
          }
          .r2 {
            font-size: 24px;
            color: #777;
            height: 80px;
            overflow: hidden;
          }
        }
      }
    }

    .item-page {
      height: 160px;
      display: flex;
      align-items: center;
      justify-content: center;
      :deep(.el-pagination) {
        button, li {
          background-color: transparent;
          width: 50px;
          height: 50px;
          border: 2px solid #e5e5e5;
          border-radius: 5px;
          color: #777;
          font-size: 24px;
          font-weight: normal;
          margin-right: 30px;
        }
        button {
          border: 0 none;
        }
        .el-pagination__jump {
          color: #777;
          font-size: 26px;
        }
        .el-pagination__editor {
          min-width: 50px;
          min-height: 50px;
          font-size: 24px;
        }
        .el-input__wrapper {
          padding: 0;
        }
        .el-input__inner {
          color: #777 !important;
        }
      }
    }
   
  }
</style>